package com.znh.entity;

import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @version 1.0
 * @Author znh
 * @Date 2024/5/23 下午4:37
 * @注释 棋盘
 */
public class Board {
    private Path path = Paths.get("images" + File.separator + "qipan.jpg");

    /**
     * 绘制棋盘
     *
     * @param g
     * @param panel
     */
    public void draw(Graphics g, JPanel panel) {
        Image image = Toolkit.getDefaultToolkit().getImage(path.toString());
        g.drawImage(image, 0, 0, panel);
    }

    /**
     * 坐标是否在棋盘内
     *
     * @param point
     * @return true:在棋盘内
     */
    public static boolean isInboard(Point point) {
        return !(point.x < 1 || point.x > 9 || point.y < 1 || point.y > 10);
    }

}
